package com.system.blogAdmin.projectmanage.controller;

/**
 * Created by c9131 on 2017-09-27.
 */

import com.cnc.common.web.util.MessageBox;
import com.system.blogAdmin.projectmanage.vo.FileForm;
import org.apache.commons.fileupload.FileItem;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;

/**
 *
 */
@Controller
@RequestMapping(value = "/fileManager")
public class FileController {
    private final Logger logger = LoggerFactory.getLogger(FileController.class);
    @RequestMapping(value = "/uploadFile",method = RequestMethod.POST)
    public MessageBox uploadFile(@RequestParam(value = "fileItem", required = false)FileItem file,String name){
        //FileForm fileForm
        System.out.println("进入"+name);
        System.out.println("文件"+file.getName());
//        if(fileForm != null && fileForm.getFileItems() != null && fileForm.getFileItems().size() > 0){
//            for (FileItem fileItem : fileForm.getFileItems()) {
//                logger.info("上传的内容" + fileItem.getName() + ":" + fileItem.getFieldName() + ":" + fileItem.getSize());
//            }
//            logger.info("文件名：" + fileForm.getName());
//        }else {
//            return MessageBox.getErrorMsg("上传出错,文件名不得为空！");
//        }
        return MessageBox.getSuccessMsg("上传成功！");
    }

}
